<template>
	<view class="myOrderBox">

		<view class="orderTitle">
			<view :class="[titleFlag==0?'active':'titleItem']" @click="unpaidBtn(0)">
				商品
			</view>
			<view :class="[titleFlag==1?'active':'titleItem']" @click="unpaidBtn(1)">
				助教
			</view>
			<view :class="[titleFlag==2?'active':'titleItem']" @click="unpaidBtn(2)">
				器材
			</view>
		</view>
		<block v-if="titleFlag==0">
			<view class="artItem plr14 ptb13  mlr15 mt18 radius6  " v-for="(i,n) in orderList" :key="n"
				@click="toMain(i)">
				<view class="justify-between align-center">
					<view class="flex1 title align-center" @click.stop="toshop(i)">
						{{i.shop_name}} <uv-icon name="arrow-right"></uv-icon>
					</view>
					<view class="right ml15">
						{{i.status==0?'需支付':'已完成'}}
					</view>
				</view>
				<view v-if="i.goods.length" class=" justify-start align-center">
					<view class="flex1 justify-start mt5 mb5">
						<view class="flex-col justify-center align-center" v-for="(item, index) in  i.goods"
							:key="index">
							<image :src="item.image" mode=""></image>
							<view class="clamp	">{{item.title}}</view>
						</view>
					</view>
					<view class="price flex-col align-end justify-end">
						<text class="money">￥{{i.total_amount||0}}</text>
						<text>共{{i.goods.length}}件 </text>
					</view>
				</view>
				<text class="orderSn">
					订单编号：{{i.order_sn}}
				</text>
			</view>
		</block>
		<block v-if="titleFlag==1">
			<view class="orderItem bgWhite plr14 ptb13  mlr15 mt18 radius6  " v-for="(item,index) in orderList" :key="n"
				@click="toMain(i)">
				<view class="justify-between" style="position: relative;">
					<image style="width: 260rpx;height: 320rpx;"  :src="item.image" mode=""></image>
					<view class="flex-col orderright justify-between ">
						<view class="orderName  align-center ">{{item.name}} <text class="mlr10">({{item.type_name}})</text>   <uv-icon color="#01C588" name="star-fill"></uv-icon> {{item.eval}} </view>
						<view class="">
							{{item.shop_name}} 
						</view>
					    <view class="justify-start align-center">
					        <text class="mr15">年龄：{{item.age}}岁</text>
					        <text>  学历：{{item.xueli}}</text>
					    </view>
						<view class="">
							段位：{{item.level||""}}段
						</view>
					    <view class="justify-between align-center" v-if="item.time_arr">
					        <view class="remark clamp">
					            时间：{{item.beizhu||""}}
					        </view>
					            
					    </view>
					</view>
					<view class="tagStatus">
					    <text class="point"></text>
					    {{item.status==1?"工作中":'空闲' }}
					</view>
				</view>
					<uv-line margin="30rpx 0"></uv-line>
					<view class="justify-end">
						<view class="apply"> 取消预约 </view>
					</view>
					
			</view>
		</block>
		<block v-if="titleFlag==2">
			<view class="artItem plr14 ptb13  mlr15 mt18 radius6  " v-for="(i,n) in orderList" :key="n"
				@click="toMain(i)">
				<view class="justify-between align-center">
					<!-- <view class="flex1 title align-center" @click.stop="toshop(i)">
						{{i.shop_name}} <uv-icon name="arrow-right"></uv-icon>
					</view> -->
                        <text class="money">总价 ￥{{i.total_amount||0}}</text>
					<view class="right ml15 mt10">
						{{i.status==0?'未支付':'已完成'}}
					</view>
				</view>
				<view v-if="i.mall_list.length" >
					<block v-for="(item,index) in i.mall_list">
					<view class="justify-between align-center">
						<view class="flex1 title align-center" >
							{{item.mall_name}} <uv-icon name="arrow-right"></uv-icon>
						</view>
						
					</view>
					<view v-if="item.goods.length" class=" justify-start align-center">
						<view class="flex1 justify-start mt5 mb5">
							<view class="flex-col justify-center align-center" v-for="(j, q) in  item.goods"
								:key="q">
								<image :src="j.image"  mode=""></image>
								<view class="clamp	">{{j.title}}</view>
							</view>
						</view>
						<view class="price flex-col align-end justify-end">
							<text class="money">￥{{item.total_amount||0}}</text>
							<text>共{{item.goods.length}}件 </text>
						</view>
					</view>
					</block>
				</view>
				<text class="orderSn">
					订单编号：{{i.order_sn}}
				</text>
			</view>
		</block>
		<view class="" v-if="orderList.length==0">
			<uv-empty mode="data" icon="https://cdn.uviewui.com/uview/empty/data.png"></uv-empty>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				titleFlag: 0,
				orderList: [{

				}],
				allCarData: [],
				orderItem: {},
				imgList: [],
				user_id: uni.getStorageSync('userId'),
				page: 1

			};
		},
		onLoad() {
			this.getOrder()
		},
		onShow() {
			// if (!uni.getStorageSync('logintoken')) {
			// 	uni.reLaunch({
			// 		url: '/pages/login/login'
			// 	})
			// 	return
			// }
			// this.getOrder()
		},
		methods: {
			formateTime(data) {
				return this.$utils.formatDateTime(data)
			},
			//立即支付
			payBtn() {
				uni.navigateTo({
					url: '/pages/mine/payment'
				})
			},
			//更多照片

			//验证车弹窗关闭
			carImgClose() {
				this.$refs.checkCar.close();
			},
			async getOrder() {
				let data;
                let data1;
				if (this.titleFlag == 0) {
					data = await this.$api.shopGoods({
						page: this.page
					})
				} else if (this.titleFlag == 1) {
					data = await this.$api.myShopAssistantOrder({
						page: this.page
					})
                   data1=await  this.$api.yuyueAssistantOrder({page:1})
                    data.list = [...data.list,...data1.list]
				} else {
					data = await this.$api.mallOrder({
						page: this.page
					})
				}
				console.log(data)

				this.orderList = data.list
			},

			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			//待支付按钮
			unpaidBtn(type) {
				this.page = 1
				this.orderList = []
				this.titleFlag = type
				this.getOrder()
			},

			//合同按钮
			contractBtn() {
				this.$refs.dzContract.open();
			},
			//合同弹窗关闭
			contractClose() {
				this.$refs.dzContract.close();
			},
			//全部车辆弹窗
			allCarBtn(data) {
				this.orderItem = data
				this.allCarData = JSON.parse(data.car_arr)
				this.$refs.carModal.open();
			},
			//车辆弹窗关闭
			carClose() {
				this.$refs.carModal.close();
			},
			async showAllImg(item) {
				const {
					data
				} = await this.$api.cartImage({
					order_id: item.id
				})
				console.log(data)
				this.imgList = data.list
				this.$refs.checkCar.open();
			},
			async getImglist(id) {
				const {
					data
				} = await this.$api.cartImage({
					order_id: id
				})

				return data.list
			},
			toMain(item) {

				// uni.navigateTo({
				// 	url: '/pages/orderDetail/index?id=' + item.orderno
				// })
			},
			submitpz(id) {
				uni.navigateTo({
					url: '/pages/pay/index?id=' + id
				})
			},
			toshop(i) {
				uni.navigateTo({
					url: '/pages/store/index?shop_id=' + i.shop_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.myOrderBox {
		min-height: 100vh;
		position: relative;
		background-color: RGBA(245, 245, 245, 1);

		.orderTitle {
			width: 750rpx;
			height: 98rpx;
			background-color: #FFFFFF;
			display: flex;
			font-size: 26rpx;
			color: #666666;
			border-bottom: 2rpx solid rgba(151, 151, 151, 0.062);

			.titleItem {
				height: 98rpx;
				line-height: 98rpx;
				text-align: center;
				flex-basis: 0rpx;
				flex-grow: 1;
				font-weight: 600;
			}

			.active {
				height: 98rpx;
				line-height: 98rpx;
				text-align: center;
				flex-basis: 0rpx;
				flex-grow: 1;
				font-weight: bold;
				font-size: 30rpx;
				color: #00C584;
				position: relative;

			}

			.active::after {
				position: absolute;
				content: "";
				width: 74rpx;
				height: 4rpx;
				bottom: 0rpx;
				left: 50%;
				transform: translateX(-50%);
				background: #2CC6A1;
			}
		}

	}

	.submitPz {
		width: 165rpx;
		height: 54rpx;
		background: #434343;
		border-radius: 6rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 54rpx;
	}

	.artItem {
		box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.0612);
		background-color: #fff;
		font-size: 24rpx;
		color: #9F9F9F;
		margin-bottom: 36rpx;

		image {
			width: 132rpx;
			height: 132rpx;
			border-radius: 10rpx;

		}

		.right {

			font-size: 28rpx;
			color: #666666;

		}

		.title {
			font-weight: bold;
			font-size: 30rpx;
			color: #111111;
		}
	}

	.price {
		font-weight: 400;
		font-size: 24rpx;
		color: #666666;
		width: calc(100% - 500rpx);

	
	}
    .money {
    	font-weight: bold;
    	font-size: 28rpx;
    	color: #222222;
    
    }
	.orderItem {
		font-size: 24rpx;
		color: #333;
		
		image {
			width: 205rpx;
			height: 205rpx;
			border-radius: 15rpx;
			margin-right: 20rpx;
	
		}
	
		.orderright {
			width: 376rpx;
	
			.orderName {
				font-weight: bold;
				font-size: 26rpx;
				color: #1C1C1C;
			}
	
			.price {
				color: #2CC6A1;
				font-size: 26rpx;
			}
		}
	
		.apply {
			width: 140rpx;
			height: 48rpx;
			background: #00C584;
			
			
			border-radius: 60rpx;
			line-height: 54rpx;
			text-align: center;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}
	.tagStatus{
	    align-items: center;
	    display: flex;
	    font-weight: 400;
	    font-size: 20rpx;
	    padding: 6rpx 9rpx 6rpx 15rpx;
	    background: rgba(255,255,255,0.7);
	    justify-content: center;
	    width: auto;
	        display: inline-flex;
	        left: 16rpx;
	        position: absolute;
	        border-radius: 15rpx ;
	       bottom: 20rpx;
	        color: #fff;
	    .point{
	        width: 8rpx;
	        height: 8rpx;
	        border: 1px solid #FFFFFF;
	        background-color: #25CE87;
	        border-radius: 50%;
	        display: inline-block;
	        margin-right: 4rpx;
	    }
	}
</style>